#include "stdafx.h"
#include "CameraClass.h"


CCameraClass::CCameraClass(void) : m_fXPosition(0.0f), m_fYPosition(0.0f), m_fZPosition(0.0f), m_fXRotation(0.0f), m_fYRotation(0.0f), m_fZRotation(0.0f)
{
}


CCameraClass::~CCameraClass(void)
{
}

void CCameraClass::SetPosition(float fXPos, float fYPos, float fZPos)
{
	m_fXPosition = fXPos;
	m_fYPosition = fYPos;
	m_fZPosition = fZPos;
}

void CCameraClass::SetRotation(float fXRot, float fYRot, float fZRot)
{
	m_fXRotation = fXRot;
	m_fYRotation = fYRot;
	m_fZRotation = fZRot;
}

D3DXVECTOR3 CCameraClass::GetPosition()
{
	return D3DXVECTOR3(m_fXPosition, m_fYPosition, m_fZPosition);
}

D3DXVECTOR3 CCameraClass::GetRotation()
{
	return D3DXVECTOR3(m_fXRotation, m_fYRotation, m_fZRotation);
}

void CCameraClass::Render()
{
	D3DXVECTOR3 d3dUp(0, 1.0f, 0);
	D3DXVECTOR3 d3dPosition(m_fXPosition, m_fYPosition, m_fZPosition);
	float fRadians = m_fYRotation * 0.0174532925f;
	D3DXVECTOR3 d3dLookAt(sinf(fRadians) + m_fXPosition, m_fYPosition, cosf(fRadians) + m_fZPosition);

	
	//float fYaw = m_fYRotation * 0.0174532925f;
	//float fPitch = m_fXRotation * 0.0174532925f;
	//float fRoll = m_fZRotation * 0.0174532925f;

	//D3DXMATRIX d3dRotationMatrix;
	//
	//D3DXMatrixRotationYawPitchRoll(&d3dRotationMatrix, fYaw, fPitch, fRoll);
	//
	//D3DXVec3TransformCoord(&d3dLookAt, &d3dLookAt, &d3dRotationMatrix);
	//D3DXVec3TransformCoord(&d3dUp, &d3dUp, &d3dRotationMatrix);
	//
	//d3dLookAt = d3dPosition + d3dLookAt;

	D3DXMatrixLookAtLH(&m_d3dViewMatrix, &d3dPosition, &d3dLookAt, &d3dUp);
}

void CCameraClass::GetViewMatrix(D3DXMATRIX& d3dView)
{
	d3dView = m_d3dViewMatrix;
}
